class AuthenticationManager
{
private:
    int timeToLive;
    unordered_map<string, int> mp;
public:
    AuthenticationManager(int timeToLive)
    {
        this->timeToLive = timeToLive;
    }

    void generate(string tokenId, int currentTime)
    {
        mp[tokenId] = currentTime + timeToLive;
    }

    void renew(string tokenId, int currentTime)
    {
        if (mp.count(tokenId) && mp[tokenId] > currentTime)
        {
            mp[tokenId] = currentTime + timeToLive;
        }
    }

    int countUnexpiredTokens(int currentTime)
    {
        int res = 0;
        for (auto &[_, time] : mp)
        {
            if (time > currentTime)
            {
                res++;
            }
        }
        return res;
    }
};